pbsOrientationRedirectURL = "/applications/scholarships/index.cfm?view=editScholarProfile&Claim_ID=";
resizeModal = function(modalId) {
	var modalHeight = $("#" + modalId).height();
	var modalBodyHeight = modalHeight - 139;
	$("#" + modalId + " .modal-body").css("min-height", modalBodyHeight);
	$("#" + modalId + " .modal-body").css("max-height", modalBodyHeight);
	$("#" + modalId + " .modal-body").css("height", modalBodyHeight);
}
resizeAppealModal = function(modalId) {
	//var modalHeight = $("#" + modalId).height();
	//var modalBodyHeight = modalHeight - 139;
	$("#" + modalId + " .modal-body").css("min-height", 500);
	$("#" + modalId + " .modal-body").css("max-height", 600);
	$("#" + modalId + " .modal-body").css("height", 600);
}
toggleFilter = function(filterId) {
	if ($("#" + filterId).is(":visible")) {
		$("#" + filterId).hide();
		$("#filterLink").text("Show filters");
	} else {
		$("#" + filterId).show();
		$("#filterLink").text("Hide filters");
	}
}
toggle = function(idToShow, idToHide) {
	$("#" + idToHide).hide();
	$("#" + idToShow).show();
}
isValidDate = function (value, userFormat) {
  var 
  userFormat = userFormat || 'm/d/yyyy', // default format
  delimiter = /[^mdy]/.exec(userFormat)[0],
  theFormat = userFormat.split(delimiter),
  theDate = value.split(delimiter),
  isDate = function (date, format) {
    var m, d, y
    for (var i = 0, len = format.length; i < len; i++) {
      if (/m/.test(format[i])) m = date[i]
      if (/d/.test(format[i])) d = date[i]
      if (/y/.test(format[i])) y = date[i]
    }
    return (
      m > 0 && m < 13 &&
      y && y.length === 4 &&
      d > 0 && d <= (new Date(y, m, 0)).getDate()
    )
  }
  return isDate(theDate, theFormat)
}
isInt = function(value) {
	var intRegex = /^\d+$/;
	return intRegex.test(value);
}
navToggle = function(nav) {
	$("#" + nav).dropdown("toggle");
}
openAppeal = function(fwaID) {
	$("#appealModal_" + fwaID).modal();
	$("#appealModal_" + fwaID + " .modal-body").css("max-height", 500);
	$("#appealModal_" + fwaID + " .modal-body").css("min-height", 500);
	$("#appealModal_" + fwaID + " .modal-body").css("height", 500);
}
closeAppeal = function(fwaID) {
	$("#appealModal_" + fwaID).modal("hide");	
}
saveAppeal = function(fwaID) {
	var args = {};
	args.objType = "fundWorkshopAppeal";
	args.Fund_Workshop_Appeal_ID = fwaID;
	args.Approved = $("#Approved_" + fwaID).val()
	args.Response = $("#Response_" + fwaID).val();
	console.log(args);
	$.ajax({
		url: "/assets/calgrants/com/API.cfc?method=update",
		data: args,
		dataType: "json",
		success: function(response) {
			if (args.Approved == true) {
				$("#appealButton_" + fwaID).removeClass("btn-danger").addClass("btn-success");
				$("#appealStatus_" + fwaID).text("Approved");
			} else {
				$("#appealButton_" + fwaID).removeClass("btn-danger").addClass("btn-warning");
				$("#appealStatus_" + fwaID).text("Rejected");
			}					
			closeAppeal(fwaID);
			return true;
		},
		error: function(response) {
			alert("There was an error saving the Fund Workshop Appeal");
			console.log(response);
			return false;
		}
	})
}
$(function(){
	//$("#timeline-indicator").css({"left": calculateTimelineProgress()});
	//$("body").css("background-color", "#54b1cd");
	
})
